<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>商品修改页面</h1>
<div>
  <input type="text" placeholder="商品编号" v-model="product.id">
  <input type="text" placeholder="商品标题" v-model="product.title">
  <input type="text" placeholder="商品价格" v-model="product.price">
  <input type="text" placeholder="库存" v-model="product.num">
  <input type="button" @click="update()" value="修改商品">


</div>




<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: 'body>div',
        data: {
          product:{
            id:"",
            title:"",
            price:"",
            num:""
          }
        },
        methods: {
          update(){

            axios.post("/update",v.product).then(function (response) {
                alert("修改完成!")
                location.href="/list.html";
            })
          }
        },
        created:function (){
            axios.get("/selectById"+location.search).then(function (response) {
                v.product = response.data

            })
        }
    })
</script>
</body>
</html>